

			function showMap(sName, cName, stateStr){
				cName = decodeURIComponent(cName.replace(/\+/g,  " "));
				var stateList = stateStr.split(/;\s*/);
				cName = cName.replace(/'/,"\'");
				var species = new Species(sName, cName, stateList);
	
				splist.ShowSpeciesInformation(species); 	
			
			}
			
			function loadDataTable(stateName){	
				 
				$('#stateName').html( ' : ' + stateName);
				var spListSourceURL = '/data?type=splist&state=' + stateName;
				var changeListSourceURL = '/data?type=changelist&state=' + stateName;
				var omissionListSourceURL = '/data?type=omissionlist&state=' + stateName;
				
				if(speciesListTable == null){
					speciesListTable = $('#sgcnTBL').dataTable({
						"bJQueryUI": true,
						"sPaginationType": "full_numbers",
						"sAjaxSource": spListSourceURL,
						"bDestroy" : true,
						"fnDrawCallback": function() {
							var oSettings = this.fnSettings();
							var iTotalRecords = oSettings.fnRecordsTotal();	
								if(iTotalRecords > 0){									
									$("#totalSpeciesCount").html(iTotalRecords);   
								}
								 
							}					 
					});
				}
				else {
					speciesListTable.fnReloadAjax( spListSourceURL );
				}
				
				
				/* Show an example parameter from the settings */
			
				
				if(speciesChangeListTable == null){
					speciesChangeListTable = $('#sgcnChangeTBL').dataTable({
						"bJQueryUI": true,
						"sPaginationType": "full_numbers",
						"sAjaxSource": changeListSourceURL,
						"bDestroy" : true,
						"fnDrawCallback": function() {
						var oSettings = this.fnSettings();
						var iTotalRecords = oSettings.fnRecordsTotal();	
							if(iTotalRecords > 0){									
								$("#changedSpeciesCount").html(iTotalRecords);   
							}
							 
						}	
						
					});
					 
				}
				else {
					speciesChangeListTable.fnReloadAjax( changeListSourceURL );
				}	
				
				if(speciesOmissionListTable == null){
					omissionListSourceURL = $('#sgcnOmissionTBL').dataTable({
						"bJQueryUI": true,
						"sPaginationType": "full_numbers",
						"sAjaxSource": omissionListSourceURL,
						"bDestroy" : true
					});
				}
				else {
					speciesOmissionListTable.fnReloadAjax( omissionListSourceURL );
				}	
			}
			
			function loadDefaultData(){
			
				var _url = defaultDataFile;

				$.ajax({
					dataType: "json",
					url: _url,
					async: false,
					ifModified: true,
					success: function(string) {
						//data = $.parseJSON(string);
						 
						defaultData = string;
						 
					},
					failure: function(msg){
						alert(msg);
					}
				});

				for(var state in defaultData.state){
							stateList[state] = defaultData.state[state];
							stateCount++;
				}
				for(var taxa in defaultData.taxa){
						 
							taxaList[taxa] = defaultData.taxa[taxa];
							taxaCount++;
				}
				
				var data =  GetFormattedDataTable( stateCount,  stateList, 'State', 'GCN Species');
				return data;
				
			}
			
			function GetFormattedDataTable(count, list, col1Label, col2Label){

				var data = new google.visualization.DataTable();
					
				data.addColumn('string', col1Label);
				data.addColumn('number', col2Label);
				
				var item = '';
				var speciesCount = 0;

				//data.addRows(count); 
				var i = 0;
				for(var item in list){
					if(col1Label == 'State' && i > 49) { break; }
						var speciesCount = list[item];
						data.addRow([item, speciesCount]);
						//data.setValue(i,0,item);
						//data.setValue(i,1, speciesCount);
						
						i++;
				
				}
			 
				return data;
			}
			
			function drawGeoMapBasedFilter(data){
			
				var mapOptions = {}; 
				mapOptions['region'] = 'US';
				mapOptions['width'] = 400;
				mapOptions['height'] = 421;
				mapOptions['colors'] = [0xFFC5A1,  0xd04020]; //orange colors
				mapOptions['title'] = 'Browse By State';
				mapOptions['dataMode'] = 'regions';
				var geomap = new google.visualization.GeoMap(document.getElementById('map'));
				google.visualization.events.addListener(geomap, 'regionClick', function(e) {      
					var stateName = extract_state(e['region']);
				
					loadDataTable(stateName);
						 
				});
				geomap.draw(data, mapOptions);
			}
			
			function extract_state(stateAbbr){
 
				if(!stateAbbr.match(/US-/)){
				 
					return stateAbbr;
				}
				var state = stateAbbr.replace(/US-/,'');
				
				state = stateAbbrIndex[state];
				return state;
			 }
			

			
